gameScene=class("gameScene",function()
    return cc.Scene:createWithPhysics()
        --    cc.Label:getReferenceCount()
end)
gameScene.__index=gameScene
gameScene._Panel_pro=nil
gameScene._Panel_pro_point=nil
gameScene._layer=nil
gameScene._start_point=nil
gameScene._numbers=0
gameScene._starts=nil
gameScene._endLayer=nil
gameScene._pausedLayer=nil
gameScene._score=0
gameScene._isHaveScore=false
gameScene._state=-1
gameScene._widget=nil
gameScene._currentStarIndex=nil
gameScene._currentClassIndex=nil --相对于单元
gameScene._currentGameIndex=nil --相对于课
gameScene._isOut = false --是否退出了游戏
gameScene._openTag= false
XSMainMapSceneCurGameOrder = nil--相对于星球
SSMainMapSceneCurGameOrder = nil
BSMainMapSceneCurGameOrder = nil
isNewGame = false
isCloseEnd = false -- endlayer关闭按钮退出
gameScene._spriteL=nil
gameScene._spriteR=nil
gameScene._game_id=nil

local function getGameOrder(unitIndex,classIndex,gameIndex)
    local _unit_id = local_data.get_unit_id_by_unitIndex(gameManger.getCurSatrt(),unitIndex)
    local gameId = local_data.get_gameId_by_cIdx_gIdx(gameManger.getCurSatrt(),_unit_id,classIndex,gameIndex)
    local gameOrder = local_data.get_game_order_classType_gameId(gameManger.getCurSatrt(),gameId)
    return gameOrder
end
local function getUnitClassGameIndexByOrder(gameOrder)
    local courseId = local_data.get_courseId_by_gameOrder(gameManger.getCurSatrt(),gameOrder)
    local unitId = local_data.get_unitId_by_gameOrder(gameManger.getCurSatrt(),gameOrder)
    local gameId = local_data.get_gameId_by_gameOrder(gameManger.getCurSatrt(),gameOrder)
    local _unit_Index = local_data.get_unit_index_class(gameManger.getCurSatrt(),unitId)
    local _class_Index = local_data.get_course_index_class_and_unit(gameManger.getCurSatrt(),unitId,courseId)
    local _game_Index = local_data.get_game_index_course_byid(gameId)
    return _unit_Index,_class_Index,_game_Index
end

function gameScene:addUI(_game_id)
cclog("addUi------>".._game_id)
    self._game_id=_game_id
    self._layer=cc.Layer:create()
    self._widget = ccs.GUIReader:getInstance():widgetFromJsonFile("startUi.json")
    local _winSize=cc.Director:getInstance():getOpenGLView():getFrameSize()
    if _WH>1.6 then
        ccs.ActionManagerEx:getInstance():playActionByName("startUi.json","show_1")
    elseif _WH>1.4 then
        ccs.ActionManagerEx:getInstance():playActionByName("startUi.json","show_3")
    end
    self._layer:addChild(self._widget,50)
    self._spriteL=cc.Sprite:create("gameLoading/guochang_left.png")
    self._spriteL:setAnchorPoint(cc.p(0,0.5))
    self._spriteL:setPosition(0,384)
    self._layer:addChild(self._spriteL,199)
    self. _spriteR=cc.Sprite:create("gameLoading/guochang_right.png")
    self._spriteR:setAnchorPoint(cc.p(1,0.5))
    self._spriteR:setPosition(1382,384)
    self._layer:addChild(self._spriteR,199)
    self:addChild(self._layer,50)
    self:initStartUI()
    local _buttonBack=self._widget:getChildByName("Button_back")
    local function eventButtonBack(sender, eventType)
        if eventType == ccui.TouchEventType.ended and self._openTag==true then
            AudioEngine.playEffect("uimusic/anniu.mp3",false)
            AudioEngine.pauseMusic()
            AudioEngine.stopAllEffects()
            cc.Director:getInstance():pause()
            require "myPlatform"
            myPlatform.set_paused(true)
--            mFile:set_paused(true)
            self:pause()
        end
    end
    _buttonBack:addTouchEventListener(eventButtonBack)
    if nil ~= self._layer then
        local function onNodeEvent(event)
            if "enter" == event then
                cclog("----xxxx".._game_id)
                local _layer=gameManger.get_game_layer(_game_id)
                self._layer:addChild(_layer,25)
                self:show_open()
            elseif "exit" == event then

            end
        end
        self._layer:registerScriptHandler(onNodeEvent)
    end
end
---------------------------------------------------------------------------------
function gameScene:movePer(_fen,startPoint)
    cclog("gameScene:movePer")
    --    if 1==1 then return end
    self._score=_fen
    if startPoint~=nil then
        local _par = cc.ParticleSystemQuad:create("particle/XF.plist")
        self._layer:addChild(_par, 100)
        _par:setTag(631)
        _par:setPosition(startPoint)
        local _endPoint= cc.pAdd(self._Panel_pro_point,cc.p(390*_fen/100,0))
        local bezier = {
            cc.p(1800/2,500/2),
            cc.p(200/2,1000/2),
            _endPoint
        }
        local bezierForward = cc.BezierTo:create(0.5, bezier)
        _par:runAction(cc.Sequence:create(bezierForward,cc.CallFunc:create(function()
            AudioEngine.playEffect("uimusic/ui06.mp3")
        end),
        cc.DelayTime:create(0.5),
        cc.CallFunc:create(function()
            --            AudioEngine.playEffect("uimusic/ui06.mp3")
            _par:setVisible(false)
            _par:removeFromParent()
        end)))
    end
    --local _x=805/2*_fen/100--以前
    local _x=778/2*_fen/100--aaa
    local _y=self._perSprite:getPositionY()
    self._perSprite:runAction(cc.MoveTo:create(0.5,cc.p(_x,_y)))
    for k,v in ipairs(self._starts) do
        if _fen>=v.score then
            v.light:setScale(0.5)
            v.light:setVisible(true)
            v.light:runAction(cc.ScaleTo:create(0.5,1))
            table.remove(self._starts,k)
        end
    end
end
function gameScene:initproStart()
    self._starts={}
    local _star1=self._widget:getChildByName("Image_1"):getChildByName("Image")
    table.insert(self._starts,{score=50,light=_star1})
    local _star2=self._widget:getChildByName("Image_2"):getChildByName("Image")
    table.insert(self._starts,{score=80,light=_star2})
    local _star3=self._widget:getChildByName("Image_3"):getChildByName("Image")
    table.insert(self._starts,{score=100,light=_star3})
    for k,v in ipairs(self._starts) do
        v.light:setVisible(false)
    end

end
function gameScene:initStartUI()
    self:initproStart()
    self._Panel_pro=self._widget:getChildByName("Panel_pro")
    local _title=self._Panel_pro:getChildByName("Image_title")
    _title:setVisible(false)
    local _x=self._Panel_pro:getPositionX()
    local _y=self._Panel_pro:getPositionY()
    self._Panel_pro_point=cc.p(_x,_y)
    --    cclog("_x..".._x.."_y..".._y)
    local bg = cc.Sprite:create("game/state_bar_front.png")
    bg:setAnchorPoint(cc.p(0,0.5))
    bg:setPosition(0,0)
    local _clipNode=cc.ClippingNode:create()
    _clipNode:setInverted(false)
    _clipNode:setAlphaThreshold(0.5)
    _clipNode:setStencil(bg)
    _clipNode:setAnchorPoint(cc.p(0,0.5))
    self._perSprite=cc.Sprite:create("game/state_bar_front.png")
    self._perSprite:setAnchorPoint(cc.p(1,0.5))
    self._perSprite:setPositionX(0)
    _clipNode:addChild(self._perSprite)
    self._Panel_pro:addChild(_clipNode)
    self._ProgressBar=self._Panel_pro:getChildByName("Image_title")
    self._ProgressBar:setVisible(false)
    local _point=cc.p(self._ProgressBar:getPositionX(),self._ProgressBar:getPositionY())
    _clipNode:setPosition(_point)
    --    local function progree(parameters)
    --        if self._perSprite:getPositionX()<805/2 then self._perSprite:setPositionX(self._perSprite:getPositionX()+1) end
    --    end
    self:movePer(0,nil)
    local _game_id=gameManger.get_game_id()
    cclog("_game_id-->：".._game_id)
    local theScore = gameManger.get_game_score(_game_id)
   
    if theScore>0 then
        self._isHaveScore = true
    else
        self._isHaveScore = false
    end
    --debug
--    local _game_id=gameManger.get_game_id()
--    gameManger.set_score(_game_id,100,function() end)
--    gameManger.set_score("YX00000111001",100,function() end)
--    gameManger.set_score("YX00000111002",100,function() end)
--    gameManger.set_score("YX00000111003",100,function() end)
--    gameManger.set_score("YX00000111004",100,function() end)
--    gameManger.set_score("YX00000111005",100,function() end)
--    gameManger.set_score("YX00000111006",100,function() end)
--    gameManger.set_score("YX00000111007",100,function() end)
--    gameManger.set_score("YX00000111008",100,function() end)
--    gameManger.set_score("YX00000111009",100,function() end)
--    gameManger.set_score("YX00000111010",100,function() end)
--    gameManger.set_score("YX00000111011",100,function() end)
--    gameManger.set_score("YX00000111012",100,function() end)
--    gameManger.set_score("YX00000111013",100,function() end)
--    gameManger.set_score("YX00000111014",100,function() end)
--    YX00000111001
    --debug
end
local _listView=nil
function gameScene:endLayer(_starIndex,_typeIndex,_classIndex,_gameIndex,_startNum)
    --    cclog("------------->".._cur_x)
    ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("Ruru/Ruru.ExportJson")
    ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("bubu/bubu.ExportJson")
    ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("kuma/kuma.ExportJson")
    if self._state~= gameSceneState.normal and self._state~= gameSceneState.layerChange then return end
    self._state=gameSceneState.endlayer
    cclog("eddLayer－－－－－－－－－－－－－－－》")
    if _starIndex == 2 then
        self._score = _startNum
    end
    cclog("66s3d:".._starIndex.."__".._typeIndex.."__".._classIndex.."__".._gameIndex.."__".._startNum)
    local _num=gameManger.change_scoreToStart(_startNum)
--    if _startNum==100 then
--        _num=3
--    elseif _startNum>=80 then
--        _num=2
--    elseif _startNum>=50 then
--        _num=1
--    end
    local _game_id=gameManger.get_game_id()
    --    cclog("星星数："..StarNum)
    --    local theScore = gameManger.get_game_score(_game_id)
    --    if theScore>0 then
    --    	self._isHaveScore = true
    --    	else
    --        self._isHaveScore = false
    --    end
    cclog("_game_id999:".._game_id)
    gameManger.set_score(_game_id,_startNum,function() end) -- 原来的
    self._endLayer = ccs.GUIReader:getInstance():widgetFromJsonFile("endLayer_1.json")-- 统计弹窗
    self:addChild(self._endLayer,100)
--    local function init_list(_table)
--        local _listView=self._endLayer:getChildByName("Panel_left"):getChildByName("ListView")
--        for k,v in ipairs(_table) do
--            local _item=_listView:getChildByName("Image_"..k)
--            _item:setVisible(true)
--            local _name=_item:getChildByName("Label_name")
--            local _score=_item:getChildByName("Label_score")
--            local _rank=_item:getChildByName("Label_lv")
--            local _avt=_item:getChildByName("Image_avt")
--            if v.pet_id~=nil then
--                _avt:loadTexture(v.pet_id..".png")
--            end
--            _name:setString(v.name)
--            _score:setString(v.score.."分")
--            _rank:setString(v.rank)
--        end
--    end
    _listView=self._endLayer:getChildByName("Panel_left"):getChildByName("ListView")
    local function init_list(_table)
        if self._endLayer ==nil then return  end
        for k,v in ipairs(_table) do
            local _node=ccs.GUIReader:getInstance():widgetFromJsonFile("endlayerSingleUi_1.json")
            local items = _listView:getItems()
            local items_count = table.getn(items)
            _listView:insertCustomItem(_node, items_count)
            _listView:doLayout()
            _listView:getInnerContainer():sortAllChildren()
            local _item=_node:getChildByName("Image_1")
            local _name=_item:getChildByName("Label_name")
            local _score=_item:getChildByName("Label_score")
            local _avt=_item:getChildByName("Image_avt")
            if v.pet_id~=nil then
                _avt:loadTexture(v.pet_id..".png")
            end
            _name:setString(v.name)
            _score:setString(v.score.."分")
        end
    end
    gameManger.get_game_rank(_game_id,function (_state,_mes)
        if _state==200 then
            local _table=json.decode(_mes).data
            table_out("game_rank",_table)
            if _table==nil or #_table<1 then
                return
            end
            table.sort(_table,function(a,b)
                return a.rank<b.rank
            end)
            init_list(_table)
        end
    end)
    local _role
    --    cclog("client.Info.userInfo.pet_id--->"..client.Info.userInfo.pet_id)
    local function roleDecision()
        if client.Info.userInfo.pet_id=="CW0001" then
            ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("Ruru/Ruru.ExportJson")
            ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("Ruru/Ruru.ExportJson")
            _role =ccs.Armature:create("Ruru")
            _role:setScale(0.9)
            _role:getAnimation():play("standby")
        end
        if client.Info.userInfo.pet_id=="CW0002" then
            ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("bubu/bubu.ExportJson")
            ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("bubu/bubu.ExportJson")
            _role = ccs.Armature:create("bubu")
            _role:setScale(0.9)
            _role:getAnimation():play("standby")
        end
        if client.Info.userInfo.pet_id=="CW0003" then
            ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("kuma/kuma.ExportJson")
            ccs.ArmatureDataManager:getInstance():addArmatureFileInfo("kuma/kuma.ExportJson")
            _role = ccs.Armature:create("kuma")
            _role:setScale(0.35)
            _role:getAnimation():play("standby_1")
        end

        if _role~=nil then
            cclog("add---->role")

            self._endLayer:getChildByName("Panel_title"):getChildByName("Panel_role"):addChild(_role,150)
            --            _role:setPosition(691,310)
        end
    end

    roleDecision()
    local _isover=false
    ccs.ActionManagerEx:getInstance():playActionByName("endLayer_1.json","out",cc.CallFunc:create(function()
        --        ccs.ActionManagerEx:getInstance():playActionByName("endLayer_1.json","bing_1")
        ccs.ActionManagerEx:getInstance():playActionByName("endLayer_1.json","bing_".._num)
        for index = 1,_num do
            self:runAction(cc.Sequence:create(cc.DelayTime:create(0.5+(index-1)*0.65),cc.CallFunc:create(function()
                AudioEngine.playEffect("uimusic/star"..index..".mp3")
            end)))
        end
        
        AudioEngine.playEffect("uimusic/window".._num..".mp3")
        _isover=true
    end))
    local _panel=self._endLayer:getChildByName("Panel_title")
    --    local _znam=_panel:getChildByName("Panel_title"):getChildByName("Label_title_class")
    local _gnam=_panel:getChildByName("Panel_title"):getChildByName("Label_title_game")
    local _kc_index=_panel:getChildByName("Panel_title"):getChildByName("Label_16")
    local _fs=_panel:getChildByName("Panel_mes"):getChildByName("Panel_fenshu"):getChildByName("Label_70")
    --    local _lv=_panel:getChildByName("Panel_mes"):getChildByName("Panel_level"):getChildByName("Label_70_0")
    _gnam:setString(gameManger.get_gname_bugameid(gameManger.get_game_id()))
    --    _znam:setString(gameManger.get_zname_bygameid(gameManger.get_game_id()))
    _fs:setString("".._startNum)
    --    _lv:setString(""..client.Info.userInfo.lv)
    local _next=_panel:getChildByName("Button_next")
    local _flus=_panel:getChildByName("Button_retry")
    local _menu=_panel:getChildByName("Button_menu")
    local _close=_panel:getChildByName("Button_close")
    
    local function eventButtonMenu(sender, eventType)
        if eventType == ccui.TouchEventType.ended and _isover and self._isOut ==false then
            ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("Ruru/Ruru.ExportJson")
            ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("bubu/bubu.ExportJson")
            ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("kuma/kuma.ExportJson")
            self._isOut = true
            if self._isOut ==true then
                cclog("isout...")
            end
            AudioEngine.playEffect("uimusic/anniu.mp3",false)
--            AudioEngine.playEffect("uimusic/ui03.mp3")
            if _starIndex == 1 then
                gameManger.goStart(gameManger.getCurSatrt(),function()
                    cclog("_typeIndex:".._typeIndex)
                    cclog("_classIndex:".._classIndex)
                    cclog("_gameIndex".._gameIndex)
                    if self._isHaveScore == false then
                        cclog("------>_isHaveScore false")
                        isNewGame=true
                        isCloseEnd = false
                        XSMainMapSceneCurGameOrder = nil
                    else
                        isNewGame=false
                        XSMainMapSceneCurGameOrder = getGameOrder(_typeIndex,_classIndex,_gameIndex)--(_classIndex-1)*3+_gameIndex
                        cclog("endlayer----XSMainMapSceneCurGameOrder--->"..XSMainMapSceneCurGameOrder)
                    end

                    goUI(_allUI.XS_MainMapScene)

                end)
            elseif _starIndex == 2 then
                gameManger.goStart(gameManger.getCurSatrt(),function()
                    if self._isHaveScore == false then
                        isNewGame=true
                        isCloseEnd = false
                        SSMainMapSceneCurGameOrder = nil
                    else
                        isNewGame=false
                        SSMainMapSceneCurGameOrder = getGameOrder(_typeIndex,_classIndex,_gameIndex)
                    end
                    goUI(_allUI.SS_MainMapScene)
                end)
            elseif _starIndex == 3 then
                gameManger.goStart(gameManger.getCurSatrt(),function()
                    if self._isHaveScore == false then
                        isNewGame=true
                        isCloseEnd = false
                        BSMainMapSceneCurGameOrder = nil
                    else
                        --                    cclog("stvss")
                        isNewGame=false
                        BSMainMapSceneCurGameOrder = getGameOrder(_typeIndex,_classIndex,_gameIndex)
                    end
                    goUI(_allUI.BS_MainMapScene)
                end)
            else
                goUI(_allUI.QinziXuanKeScene)
            end
            --            self._endLayer:removeFromParentAndCleanup()
            self._state= gameSceneState.normal
        end
    end

    local function eventButtonClose(sender, eventType)
        if eventType == ccui.TouchEventType.ended and _isover and self._isOut ==false then
            ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("Ruru/Ruru.ExportJson")
            ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("bubu/bubu.ExportJson")
            ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("kuma/kuma.ExportJson")
            self._isOut = true
            if self._isOut ==true then
                cclog("isout...")
            end
            AudioEngine.playEffect("uimusic/ui03.mp3")
            if _starIndex == 1 then
                gameManger.goStart(gameManger.getCurSatrt(),function()
                    cclog("jkjkjjk")
                    
                    if self._isHaveScore == false then
                        cclog("------>_isHaveScore false")
                        isNewGame=true
                        isCloseEnd = true
                        XSMainMapSceneCurGameOrder = nil
                    else
                        isNewGame=false
                        XSMainMapSceneCurGameOrder = getGameOrder(_typeIndex,_classIndex,_gameIndex)
                    end

                    --                        isNewGame=true
                    --                        isCloseEnd = true
                    --                        XSMainMapSceneCurGameOrder = nil--(_classIndex-1)*3+_gameIndex
                    goUI(_allUI.XS_MainMapScene)

                end)
            elseif _starIndex == 2 then
                gameManger.goStart(gameManger.getCurSatrt(),function()
                    if self._isHaveScore == false then
                        cclog("------>_isHaveScore false")
                        isNewGame=true
                        isCloseEnd = true
                        SSMainMapSceneCurGameOrder = nil
                    else
                        isNewGame=false
                        SSMainMapSceneCurGameOrder = getGameOrder(_typeIndex,_classIndex,_gameIndex)
                    end
                    goUI(_allUI.SS_MainMapScene)
                end)
            elseif _starIndex == 3 then
                gameManger.goStart(gameManger.getCurSatrt(),function()
                    if self._isHaveScore == false then
                        cclog("------>_isHaveScore false")
                        isNewGame=true
                        isCloseEnd = true
                        BSMainMapSceneCurGameOrder = nil
                    else
                        isNewGame=false
                        BSMainMapSceneCurGameOrder = getGameOrder(_typeIndex,_classIndex,_gameIndex)
                    end
                    goUI(_allUI.BS_MainMapScene)
                end)
            else
                goUI(_allUI.QinziXuanKeScene)
            end
            --            self._endLayer:removeFromParentAndCleanup()
            self._state= gameSceneState.normal
        end
    end
    --    _flus
    --    _menu:addTouchEventListener(eventButtonMenu)--6.14删
    _next:addTouchEventListener(eventButtonMenu)
    _close:addTouchEventListener(eventButtonClose)
    local _game_id=gameManger.get_game_id()
    local function eventRgame(sender, eventType)
        if eventType == ccui.TouchEventType.ended and _isover and self._isOut==false then
            ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("Ruru/Ruru.ExportJson")
            ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("bubu/bubu.ExportJson")
            ccs.ArmatureDataManager:getInstance():removeArmatureFileInfo("kuma/kuma.ExportJson")
            self._isOut=true
            AudioEngine.playEffect("uimusic/anniu.mp3",false)
            --            require "date_game"
            --            local _next_id=date_game.get_gameID_by_pre_game(_game_id)
            --            if _next_id~=nil then
            --                cclog("nonil")
            gameManger.go_game(_game_id)
            --                else
            --                cclog("nil")
            --            end
            self._state= gameSceneState.normal
        end
    end
    _flus:addTouchEventListener(eventRgame)
end
function gameScene:pause()
    --    cclog("------------->".._cur_x)
    require "gameManger"
    require "local_data"
    local _classType_id=gameManger.getCurSatrt()--星球id
    local _starIndex=gameManger.getCurSatrt_index()--星球index
    local _course_id=local_data.get_course_id_by_gameId(self._game_id)--课程id
    local _unit_id=local_data.get_unit_id_by_courseId(_course_id)
    self._currentUnitIndex=local_data.get_unit_index_class(_classType_id,_unit_id)--课程index
    self._currentClassIndex=local_data.get_course_index_class_and_unit(_classType_id,_unit_id,_course_id)--课程index
    self._currentGameIndex=local_data.get_game_index_course(_course_id,self._game_id)--游戏索引
    cclog("self._currentUnitIndex:"..self._currentUnitIndex)
    cclog("self._currentClassIndex:"..self._currentClassIndex)
    cclog("self._currentGameIndex:"..self._currentGameIndex)
    if self._state~= gameSceneState.normal then return end
    self._state=gameSceneState.pause
    if  self._pausedLayer==nil then
        self._pausedLayer = ccs.GUIReader:getInstance():widgetFromJsonFile("pauseUi.json")
        self._layer:addChild(self._pausedLayer,100)
        --        cc.Director:getInstance():pause()
    end
    local function showOver()
        --        cclog("7000r")
        cc.Director:getInstance():stopAnimation()
        cc.Director:getInstance():pause()

        --        mFile:set_paused(true)
    end
    self._pausedLayer:setVisible(true)
    ccs.ActionManagerEx:getInstance():playActionByName("pauseUi.json","show",cc.CallFunc:create(showOver))
    local _panel=self._pausedLayer:getChildByName("Panel_title")
    --    local _znam=_panel:getChildByName("Panel_title"):getChildByName("Label_title_class")--课程标签aaa
    local _gnam=_panel:getChildByName("Panel_title"):getChildByName("Label_title_game")--小游戏标签aaa
    local _game_index=_panel:getChildByName("Panel_title"):getChildByName("Label_16")--小游戏标签aaa
    _gnam:setString(gameManger.get_gname_bugameid(gameManger.get_game_id()))
    --    _znam:setString(gameManger.get_zname_bygameid(gameManger.get_game_id()))
    local _close=_panel:getChildByName("Image_46"):getChildByName("Button_close")
    local _resume=_panel:getChildByName("Image_46"):getChildByName("Button_next")
    local _menu=_panel:getChildByName("Image_46"):getChildByName("Button_menu")
    local _mes=_panel:getChildByName("Image_46"):getChildByName("Image_47"):getChildByName("Label_message")
    --    local _Image_title=_panel:getChildByName("Image_title")--提示画面aaa
    --    _Image_title:loadTexture("lead_guide_"..typdIndex.."_"..classIndex.."_"..gameIndex..".png")
    local function eventButtonMenu(sender, eventType)
        if eventType == ccui.TouchEventType.ended and self._isOut==false then
            cclog("self._isOut==false")
            self._isOut=true
            if self._isOut ==true then
                cclog("isOut now")
            end
            AudioEngine.playEffect("uimusic/anniu.mp3",false)
            --            AudioEngine.resumeMusic()
            --            AudioEngine.resumeAllEffects()
            cc.Director:getInstance():startAnimation()
            cc.Director:getInstance():resume()
            require "myPlatform"
            myPlatform.set_paused(false)
--            mFile:set_paused(false)
--            AudioEngine.playEffect("ui03.mp3")
            if _starIndex == 1 then --依据判断进入哪个场景aaa
                cclog("self._currentUnitIndex:"..self._currentUnitIndex)
                cclog("self._currentClassIndex:"..self._currentClassIndex)
                cclog("self._currentGameIndex:"..self._currentGameIndex)
                isNewGame=false
                if self._isHaveScore == false then

                    XSMainMapSceneCurGameOrder = nil
                else
                    --                    isNewGame=false
                    XSMainMapSceneCurGameOrder = getGameOrder(self._currentUnitIndex,self._currentClassIndex,self._currentGameIndex)
                    cclog("XSMainMapSceneCurGameOrder:"..XSMainMapSceneCurGameOrder)
                end
                gameManger.goStart(local_data.classType.xueshi,function()
                    goUI(_allUI.XS_MainMapScene)
                end)
            elseif _starIndex == 2 then --
                isNewGame=false
                if self._isHaveScore == false then
                    --                    isNewGame=true
                    cclog("noscroere")
                    SSMainMapSceneCurGameOrder = nil
                else
                    cclog("hasscroere")
                    SSMainMapSceneCurGameOrder = getGameOrder(self._currentUnitIndex,self._currentClassIndex,self._currentGameIndex)
                end
                gameManger.goStart(local_data.classType.shuoshi,function()
                    goUI(_allUI.SS_MainMapScene)
                end)
            elseif _starIndex == 3 then --
                isNewGame=false
                if self._isHaveScore == false then
                    --                    isNewGame=true
                    BSMainMapSceneCurGameOrder = nil
                else
                    --                    isNewGame=false
                    BSMainMapSceneCurGameOrder = getGameOrder(self._currentUnitIndex,self._currentClassIndex,self._currentGameIndex)
                end
                gameManger.goStart(local_data.classType.boshi,function()
                    goUI(_allUI.BS_MainMapScene)
                end)

            else
                goUI(_allUI.QinziXuanKeScene)
            end
            self._state= gameSceneState.normal
        end
    end
    _menu:addTouchEventListener(eventButtonMenu)
    local function eventResume(sender, eventType)
        if eventType == ccui.TouchEventType.ended then
            --            self._layer:removeChild(self._pausedLayer)
            AudioEngine.playEffect("uimusic/anniu.mp3",false)
            self._pausedLayer:setVisible(false)
            AudioEngine.resumeMusic()
--            AudioEngine.resumeAllEffects()
            cc.Director:getInstance():startAnimation()
            cc.Director:getInstance():resume()
            --            cc.Director:getInstance():stopAnimation()
            require "myPlatform"
            myPlatform.set_paused(false)
--            mFile:set_paused(false)
--            AudioEngine.playEffect("ui02.mp3")
            self._state= gameSceneState.normal
        end
    end
    _resume:addTouchEventListener(eventResume)
    _close:addTouchEventListener(eventResume)
    local _flus=_panel:getChildByName("Image_46"):getChildByName("Button_rgame")
    local _game_id=gameManger.get_game_id()
    local function eventRgame(sender, eventType)
        if eventType == ccui.TouchEventType.ended and self._isOut==false then
            self._isOut=true
            AudioEngine.playEffect("uimusic/anniu.mp3",false)
            --            AudioEngine.resumeMusic()
            --            AudioEngine.resumeAllEffects()
            cc.Director:getInstance():startAnimation()
            cc.Director:getInstance():resume()
--            mFile:set_paused(false)
            require "myPlatform"
            myPlatform.set_paused(false)
            require "date_game"
            --            local _next_id=date_game.get_gameID_by_pre_game(_game_id)
            --            if _next_id~=nil then
            gameManger.go_game(_game_id)
            --            end
            self._state= gameSceneState.normal
        end
    end
    _flus:addTouchEventListener(eventRgame)
end
function gameScene:show_open()--开屏动画
    cclog("show________open")
    --    local _spriteL=cc.Sprite:create("gameLoading/guochang_left.png")
    --    _spriteL:setAnchorPoint(cc.p(0,0.5))
    --    _spriteL:setPosition(0,384)
    --    self._layer:addChild(_spriteL,199)
    --    local _spriteR=cc.Sprite:create("gameLoading/guochang_right.png")
    --    _spriteR:setAnchorPoint(cc.p(1,0.5))
    --    _spriteR:setPosition(1382,384)
    --    self._layer:addChild(_spriteR,199)
    self._spriteL:runAction(cc.Sequence:create(cc.DelayTime:create(1),cc.MoveTo:create(1,cc.p(-1000,384))))
    self._spriteR:runAction(cc.Sequence:create(cc.DelayTime:create(1),cc.MoveTo:create(1,cc.p(2382,384)),cc.CallFunc:create(function()
        self._openTag =true
    end)))
end
------------------------------------------------------------------------
function gameScene:addLayer(_layer,_order)
    self:addChild(_layer,_order)
    --    cc.Sprite:release()
end
function gameScene:hideUiForFamily_1_1()
    self._layer:getChildByTag(787):setPosition(cc.p(3000,3000))
end
function gameScene:setPauseButtonEnabledNo()
    local _buttonBack=self._widget:getChildByName("Button_back")
    _buttonBack:setTouchEnabled(false)
end

function gameScene:setPauseButtonEnabledYes()
    local _buttonBack = self._widget:getChildByName("Button_back")
    _buttonBack:setTouchEnabled(true)
end
function gameScene.create(_game_id)
    gameSceneInstance=gameScene.new()
    -----------------------
    require "gameManger"
    gameManger.set_state(gameManger._state_list.normal)
    gameSceneInstance._state=gameSceneState.normal
    -----------------------
    gameSceneInstance._start_point={50,80,100}
    cclog("kkkssss--->".._game_id)
    gameSceneInstance:addUI(_game_id)
    cclog("------>>>>")
    return gameSceneInstance
end
cclog("gameScene--->version->1.0.0.2")